home *** CD-ROM | disk | FTP | other *** search
- XREF4
- GFA Basic variable/procedure cross referencer
- by DAEDWARDS
-
- What it is: XREF4 is a GFA Basic cross-referencer. Feed it a
- .LST file from GFA Basic, and it produces a .LNM file (like the
- .LST file with line numbers added) and a .XRF file showing every
- variable, label, and procedure name, in alphabetical order, with the line
- number of each reference to it in the program.
-
- (Qualifier: you can use names like Gosub as variables; the
- cross referencer is not smart enough to deal with that, so such
- things won't be included.)
-
- This is the 3rd version of My program; someone else wrote the
- original GFA Basic XREF, which only processed subroutine names. I
- didn't like that, so I wrote XREF2, and am now releasing XREF4.
-
- Both the GFA Basic source and the compiled version are in the
- archive. I recommend using the compiled version, and putting the
- output on a RAMdisk, for speed. But if you don't want to do that,
- it is your business.
-
-
-
- History and hacker's notes: Many mainframe compilers and
- assemblers can easily be persuaded to produce a cross-reference
- showing every place in the program where each variable is used.
- This list is sometimes quite useful in finding program bugs.
-
- Some time back, XREF was released for GFA Basic. However, it
- only cross referenced subroutines - not variables. I wasn't
- satisfied with this. So I wrote XREF2, which would do variables as
- well.
-
- However, XREF2 had some problems. The first problem to
- surface would become quite obvious three minutes after the first
- time you started running it: it would still be running. It was
- incredibly slow. But that turned out to not be the worst: due to a
- line I hadn't noticed in the GFA Basic manual, if you referred to
- the same variable too many times the thing would get lost and
- produce a cross reference list best described as "garbage". It
- was, fortunately, recognisable as garbage, which is possibly the
- smallest of virtues.
-
- When I discovered this, I decided it was time to write XREF3.
- It involved replacing one or two routines and minor improvements
- in others.
-
-
-
-
-
-
-
- When XREF3 was just about done, the last two or three bugs
- were being particularly stubborn, and I was thinking about how the
- project could have been done differently, I suddenly decided to
- give it a try. XREF3 was set aside 90% complete (one of those
- projects that proceeded quickly to 90% complete and then promised
- to remain 90% complete forever), and I started on XREF4, expecting
- either a quick success or a complete flop. I still have XREF3, but
- haven't done anything with it in the last two months or so.
-
- XREF4 is virtually a complete rewrite, except for the
- comments at the front. The single biggest improvement is probably
- the sort. In XREF2 I went with a merge sort - a useful technique,
- the fastest way to sort files which won't fit in memory -
- primarily because I could not tell in advance how big to dimension
- an array holding all the variable names.
-
- But by the time of XREF4 I had some ideas, and worked out the
- technique of making an array grow (described in a separate
- document with a much smaller and simpler sample program, in
- GROWARAY.ARC), so I went with a quicksort. No file I/O at all, and
- as a result many times faster.
-
- I also completely rewrote the front end, which reads the
- source listing, produces the numbered listing, and extracts
- names to be cross-referenced. It actually does more of the work
- now than it used to, yet still runs in about 1/3 the time of the
- older version.
-
- A minor bug in XREF2 was a STOP statement that fouled up the
- compiler (I didn't have the GFA Basic compiler when I wrote it);
- compiling it didn't help that much anyway, because file I/O
- operations were taking most of the time at every stage. XREF4
- compiles neatly, and runs signifigantly faster compiled.
-
-